/*     */ package com.zimbra.cs.session;
/*     */ 
/*     */ import com.google.common.collect.Sets;
/*     */ import com.google.common.collect.Sets.SetView;
/*     */ import com.zimbra.common.util.Log;
/*     */ import com.zimbra.common.util.ZimbraLog;
/*     */ import com.zimbra.cs.mailbox.MailItem.Type;
/*     */ import com.zimbra.cs.mailbox.Mailbox;
/*     */ import com.zimbra.cs.service.util.SyncToken;
/*     */ import java.util.Set;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class WaitSetSession
/*     */   extends Session
/*     */ {
/*  33 */   SomeAccountsWaitSet mWs = null;
/*     */   Set<MailItem.Type> interest;
/*     */   int mHighestChangeId;
/*     */   SyncToken mSyncToken;
/*     */   
/*     */   WaitSetSession(SomeAccountsWaitSet ws, String accountId, Set<MailItem.Type> interest, SyncToken lastKnownSyncToken) {
/*  39 */     super(accountId, Session.Type.WAITSET);
/*  40 */     this.mWs = ws;
/*  41 */     this.interest = interest;
/*  42 */     this.mSyncToken = lastKnownSyncToken;
/*     */   }
/*     */   
/*     */   protected boolean isMailboxListener()
/*     */   {
/*  47 */     return true;
/*     */   }
/*     */   
/*     */   protected boolean isRegisteredInCache()
/*     */   {
/*  52 */     return false;
/*     */   }
/*     */   
/*     */   void update(Set<MailItem.Type> interest, SyncToken lastKnownSyncToken) {
/*  56 */     this.interest = interest;
/*  57 */     this.mSyncToken = lastKnownSyncToken;
/*  58 */     if (this.mSyncToken != null)
/*     */     {
/*     */ 
/*     */ 
/*     */ 
/*  63 */       int mboxHighestChange = getMailbox().getLastChangeID();
/*  64 */       if (mboxHighestChange > this.mHighestChangeId)
/*  65 */         this.mHighestChangeId = mboxHighestChange;
/*  66 */       if (this.mSyncToken.after(this.mHighestChangeId)) {
/*  67 */         this.mWs.unsignalDataReady(this);
/*     */       } else {
/*  69 */         this.mWs.signalDataReady(this);
/*     */       }
/*     */     }
/*     */   }
/*     */   
/*     */   protected void cleanup() {
/*  75 */     this.mWs.cleanupSession(this);
/*     */   }
/*     */   
/*     */   protected long getSessionIdleLifetime() {
/*  79 */     return 0L;
/*     */   }
/*     */   
/*     */   public void notifyPendingChanges(PendingModifications pns, int changeId, Session source) {
/*  83 */     boolean trace = ZimbraLog.session.isTraceEnabled();
/*  84 */     if (trace) {
/*  85 */       ZimbraLog.session.trace("Notifying WaitSetSession: change id=" + changeId + ", highest change id=" + this.mHighestChangeId + ", sync token=" + this.mSyncToken);
/*     */     }
/*  87 */     if (changeId > this.mHighestChangeId) {
/*  88 */       this.mHighestChangeId = changeId;
/*     */     }
/*  90 */     if ((this.mSyncToken != null) && (this.mSyncToken.after(this.mHighestChangeId))) {
/*  91 */       if (trace) ZimbraLog.session.trace("Not signaling waitset; sync token is later than highest change id");
/*  92 */       return;
/*     */     }
/*  94 */     if (!Sets.intersection(this.interest, pns.changedTypes).isEmpty()) {
/*  95 */       if (trace) ZimbraLog.session.trace("Signaling waitset");
/*  96 */       this.mWs.signalDataReady(this);
/*     */     }
/*  98 */     else if (trace) { ZimbraLog.session.trace("Not signaling waitset; waitset is not interested in change type");
/*     */     }
/* 100 */     if (trace) ZimbraLog.session.trace("WaitSetSession.notifyPendingChanges done");
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/session/WaitSetSession.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */